package org.example.back.service.Forum;

import org.example.back.entity.Forum.ForumComment;
import org.example.back.mapper.Forum.ForumCommentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class ForumCommentService {

    @Autowired
    private ForumCommentMapper forumCommentMapper;

    public int addComment(ForumComment comment) {
        comment.setCreatedAt(LocalDateTime.now());
        return forumCommentMapper.insertComment(comment);
    }

    public List<ForumComment> getCommentsByPostId(Long postId) {
        return forumCommentMapper.selectCommentsByPostId(postId);
    }

    public int deleteComment(Long id) {
        return forumCommentMapper.deleteComment(id);
    }
}
